home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / BC_TI.ARJ / TI396.ASC < prev    next >
Text File  |  1992-02-25  |  2KB  |  67 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  TURBO C                                NUMBER  :  396
  9.   VERSION  :  1.0
  10.        OS  :  PC-DOS
  11.      DATE  :  November 18, 1987                        PAGE  :  1/1
  12.  
  13.     TITLE  :  CAPTURING INTERRUPTS
  14.  
  15.  
  16.  
  17.  
  18.   The following program demonstrates the use of getvect and setvect
  19.   to safely capture and restore interrupt vectors.  This code could
  20.   be easily modified to disable  the  print  screen  utility during
  21.   program execution.
  22.  
  23.   #include <stdio.h>
  24.   #include <dos.h>
  25.  
  26.   void interrupt (*oldfunc)();
  27.   int __LOOPING__ = 1;
  28.  
  29.   /*--------------------------------------------------------------------
  30.    * get_out - this is our new interrupt routine
  31.    *------------------------------------------------------------------*/
  32.   void interrupt get_out() {
  33.          setvect(5,oldfunc); /* restore to original interrupt routine */
  34.  
  35.        __LOOPING__ = 0;
  36.  
  37.   }
  38.  
  39.   /*--------------------------------------------------------------------
  40.    * capture_prtscr - installs a new interrupt for <Shift><PrtSc>
  41.    *  arguments :  func  -- new interrupt function pointer
  42.    *------------------------------------------------------------------*/
  43.   void capture_prtscr(void interrupt (*func)()) {
  44.        oldfunc  = getvect(5);        /* save the old interrupt */
  45.        setvect(5,func);              /* install our interrupt handler */
  46.   }
  47.  
  48.   void main () {
  49.  
  50.        puts("Press <Shift><PrtSc> to terminate");
  51.        capture_prtscr(get_out);  /* capture the print screen interrupt */
  52.  
  53.        while (__LOOPING__)
  54.          ;   /* do nothing */
  55.  
  56.        puts("Success");
  57.   }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.